using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
namespace prDe_Tai.DuLieu
{
    class dulieu_danhsachbosuutap
    {
        LayDuLieu obj = new LayDuLieu();
        public DataSet laytoanbophanmem()
        {
            return obj.thucthilenh("select * from DanhSachBoSuuTap order by tenphanmem");
        }
        
        public DataSet layphanmemtheotenphanmem(string tenphanmem)
        {
            OleDbCommand com = new OleDbCommand();
            com.CommandType = CommandType.Text;
            com.CommandText = @"SELECT DanhSachBoSuuTap.tenphanmem, DanhSachPhanMem.chude, DanhSachPhanMem.chucnang, DanhSachPhanMem.loaiphanmem, DanhSachPhanMem.diachidownload
                                FROM DanhSachBoSuuTap,DanhSachPhanMem
                                WHERE DanhSachBoSuuTap.tenphanmem=DanhSachPhanMem.tenphanmem
                                and DanhSachBoSuuTap.tenphanmem=@tenphanmem";
            com.Parameters.Add("@tenphanmem", OleDbType.BSTR).Value = tenphanmem;
            return obj.thucthilenh(com);            
        }
        
        public void themphanmemvaobang(string tenphanmem)
        {            
            OleDbCommand com = new OleDbCommand();           
            com.CommandType = CommandType.Text;
            com.CommandText = "insert into DanhSachBoSuuTap values(@tenphanmem)";           
            com.Parameters.Add("@tenphanmem", OleDbType.BSTR).Value = tenphanmem;
            obj.thucthilenhkhongtravegiatri(com);            
        }
        
        public void xoaphanmem(string tenphanmem)
        {
            OleDbConnection con = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=QuanLyPhanMem.mdb");
            OleDbCommand com = new OleDbCommand();
            com.Connection = con;
            com.CommandType = CommandType.Text;
            com.CommandText = "delete from DanhSachBoSuuTap where tenphanmem=?";
            com.Parameters.Add("?", OleDbType.BSTR).Value = tenphanmem;
            con.Open();
            com.ExecuteNonQuery();
            con.Close();
        }
    }
}
